import TableStore = require('tablestore')
import { tablestoreInfo } from '../config';

// console.log(tablestoreInfo)
const client = new TableStore.Client(tablestoreInfo)

const Long = TableStore.Long

const params = {
    tableName: "RasPi",
    primaryKey: [{ 'id': 'RasbPi3' }],
    maxVersions: 3
};
// const condition = new TableStore.CompositeCondition(TableStore.LogicalOperator.AND);
// condition.addSubCondition(new TableStore.SingleColumnCondition('name', 'john', TableStore.ComparatorType.EQUAL));
// condition.addSubCondition(new TableStore.SingleColumnCondition('addr', 'china', TableStore.ComparatorType.EQUAL));
// (params as any).columnFilter = condition;
export const getRow = (): Promise<any> => {
    return new Promise((resolve, reject) => {
        client.getRow(params, (err, data) => {
            if (err) {
                reject(err)
                return;
            }
            resolve(data.row);
        });
    })
}
